﻿using System.Text.RegularExpressions;
namespace MvcForum.Net.Bussiness
{
   public class RegexFormatter
    {
        private readonly string _replace;
        private readonly Regex _regex;

        public RegexFormatter(string pattern, string replace): this(pattern, replace, true)
        {

        }

       //public RegexFormatter(Regex _r,)


        public RegexFormatter(string pattern, string replace, bool ignoreCase)
        {
            RegexOptions options = RegexOptions.Compiled;

            if (ignoreCase)
            {
                options |= RegexOptions.IgnoreCase;
            }

            _replace = replace;
            _regex = new Regex(pattern, options);
        }

       public string Format(string data)
       {
           return _regex.Replace(data, _replace);
       }
    }
}
